<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<%@ page contentType="text/html; charset=UTF-8" errorPage="/jsp/error.jsp" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld"  prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld"  prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>



<%@ page  import="java.util.*" %>
<%@ page  import="com.erp.framework.util.CommonUtil" %>
<%@ page  import="com.erp.app.common.ProjectConstants" %>
<%@ page  import="com.erp.app.common.BBA"%>


<jsp:useBean id="bbaForm" scope="request" type="com.erp.common.web.BBAForm" />
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>BBA</title>
<STYLE TYPE="text/css"><!--
td, .table {
border:1px solid #000000;
}
.none {
border:0px;
white-space:nowrap;
}
-->
</STYLE>

<SCRIPT>
<!--
var ids = new Array("idDump_insert", "idSp_quot", "idPre_ws", "idClear_query", "idIgnore_err", "idShReal_name", "idSingle_stmt");
var cbs = new Array("isDumpInsert", "isSuppressQuotes", "isUsePre", "isClear", "isIgnoreError", "isShowRealName", "isSingleStmt");

function onSubmit() {
    var s = document.forms[0].inputQuery.value
    if ( s )
        setCookie("idQuery", s)
    for ( var i = 0; i < ids.length; i++ )
        setCookie(ids[i], document.all[ids[i]].checked)
}

function init() {
    window.status = 'Initialized'
    for ( var i = 0; i < ids.length; i++ ) {
    	var obj = document.all[ids[i]];
	if ( obj != null ) {
		obj.checked = eval(getCookie(ids[i]));
		objcb = eval('document.forms[0].'+cbs[i]);
		if (objcb != null) {
			objcb.value = obj.checked? 'Y': 'N';
		}
	}
    }
    document.forms[0].inputQuery.value = getCookie("idQuery");
}

function getCookie(name) {
    var i, s = document.cookie, iEnd
    name = escape(name) + "="
    i = s.indexOf(name)
    if ( i < 0 )
        return ""
    iEnd = s.indexOf(";", i += name.length)
    return unescape(s.substring(i, iEnd > -1 ? iEnd : s.length))
}

function setCookie(name, value) {
    var never = new Date(100 * 1000 * 3600 * 24 * 365),
        expire = setCookie.arguments.length > 2 ? setCookie.arguments[2] : never

    document.cookie = escape(name) + "=" + escape(value) + "; expires=" + expire.toGMTString() + ";"
}

function setStyle() {
    document.styleSheets[0].cssText += " td,table { white-space:pre }"
}

var tickVal = '0';
var untickVal = '1';

function doTickWithValue(cbName,idx,val1,val2) {
	tickVal = val1;
	untickVal = val2;
	doTick(cbName,idx);
	tickVal = '0';
	untickVal = '1';
}

function doTick(cbName,idx) {
	var aInput = document.getElementsByName(cbName);
	if (aInput.length) {
		selectedObj = aInput[idx];
		if (aInput.length == 1)
			selectedObj = aInput[0];
	} else {
		selectedObj = aInput;
	}
	if (selectedObj.value != null && selectedObj.value == tickVal)
		selectedObj.value = untickVal;
	else
		selectedObj.value = tickVal;
}

function doLoad() {
	<%
		if ( "Y".equals(bbaForm.getIsUsePre()) ) {
			out.println("setStyle()");
		}
	%>
	<logic:equal name="bbaForm" property="statCode" value="1" >
		init();
	</logic:equal>
}



//-->
</SCRIPT>

</HEAD>
<BODY BGCOLOR="#FFFFFF" onLoad="javascript:doLoad();">
<html:form action="/bba" enctype="multipart/form-data" onsubmit="javascript:onSubmit();">
<html:hidden property="statCode" />
<P>
<table border=0 bordercolor="#808080" cellpadding=2 cellspacing=1 width="100%" class="table">
<tr>
	<td valign="top" WIDTH=70 class="none">
		<font face="Arial">BBA</font>
	</td>
	<td valign="top" WIDTH=152 class="none">
		<font face="Arial">Version </font>
		<font SIZE=2 face="Arial"><span STYLE="font-size:12;"><%= BBA.getVersion() %></span></font>
	</td>
	<td valign="top" WIDTH=670 class="none">
		<font face="Arial"> Version Date : </font>
		<font SIZE=2 face="Arial"><span STYLE="font-size:11;"><%= BBA.getVersionDate() %></span></font>
	</td>
	<td valign="top" class="none">
		<input name="btn_logout" type="SUBMIT" value="Logout">
	</td>
</tr>
</table>
<P>
<font face=arial size=2 color=red>*** WARNING *** All transactions are committed automatically. Please BACKUP your data first!</font>

<table border=0 bordercolor="#808080" cellpadding=0 cellspacing=1 width=100% class="none">
<tr>
	<td valign="top" class="none">
		<input name="btn_query" accessKey="q" type="SUBMIT" value="Query">
		<input name="btn_update" accessKey="u" type="SUBMIT" value="Update">
		<input name="btn_save" accessKey="u" type="SUBMIT" value="Export result to Excel">
	</td>
	<td valign="top" class="none">
		<html:file property="theFile" />
		<font size="3" face="Arial"><span STYLE="font-size:14;">
		(Choose a file as query.&nbsp;Can be used for Query or Update)</span></font>
	</td>
</tr>
</table>

<table border=0 bordercolor="#808080" cellpadding=0 cellspacing=1 width=100% class="none">
<tr>
	<td valign="top" class="none"></td>
	<td valign="top" WIDTH=5% class="none"></td>
	<td valign="top" class="none">
		<font size="3" face="Arial"><span STYLE="font-size:14;">Quer<U>Y</U></span></font>
		<BR>
	</td>
</tr>
<tr>
	<td VALIGN=TOP><table border=0 bordercolor="#808080" cellpadding=2 cellspacing=1 class="none">
		<tr>
			<td valign="top" NOWRAP class="none">
				<input type="checkbox" name="isDumpInsertTmp" id="idDump_insert" accessKey="d" <%= CommonUtil.nullToString(bbaForm.getIsDumpInsert()).equals("Y")? "checked": "" %> onclick="javascript:doTickWithValue('isDumpInsert', 0, 'Y','N');"/>
				<html:hidden property="isDumpInsert" value="<%= CommonUtil.nullToString(bbaForm.getIsDumpInsert()) %>" />
				<U>D</U>ump insert
			</td>
		</tr>
		<tr>
			<td valign="top" NOWRAP class="none">
				<input type="checkbox" name="isSuppressQuotesTmp" id="idSp_quot" accessKey="s" <%= CommonUtil.nullToString(bbaForm.getIsSuppressQuotes()).equals("Y")? "checked": "" %> onclick="javascript:doTickWithValue('isSuppressQuotes', 0, 'Y','N');"/>
				<html:hidden property="isSuppressQuotes" value="<%= CommonUtil.nullToString(bbaForm.getIsSuppressQuotes()) %>" />
				<U>S</U>uppress Quote
			</td>
		</tr>
		<tr>
			<td valign="top" NOWRAP class="none">
				<input type="checkbox" name="isUsePreTmp" id="idPre_ws" accessKey="w" <%= CommonUtil.nullToString(bbaForm.getIsUsePre()).equals("Y")? "checked": "" %> onclick="javascript:doTickWithValue('isUsePre', 0, 'Y','N');"/>
				<html:hidden property="isUsePre" value="<%= CommonUtil.nullToString(bbaForm.getIsUsePre()) %>" />
				<U>W</U>hite-space use PRE mode
			</td>
		</tr>

		<tr>
			<td valign="top" NOWRAP class="none">
				<input type="checkbox" name="isClearTmp" id="idClear_query" accessKey="c" <%= CommonUtil.nullToString(bbaForm.getIsClear()).equals("Y")? "checked": "" %> onclick="javascript:doTickWithValue('isClear', 0, 'Y','N');"/>
				<html:hidden property="isClear" value="<%= CommonUtil.nullToString(bbaForm.getIsClear()) %>" />
				<U>C</U>lear Query upon request
			</td>
		</tr>
		<tr>
			<td valign="top" NOWRAP class="none">
				<input type="checkbox" name="isIgnoreErrorTmp" id="idIgnore_err" accessKey="i" <%= CommonUtil.nullToString(bbaForm.getIsIgnoreError()).equals("Y")? "checked": "" %> onclick="javascript:doTickWithValue('isIgnoreError', 0, 'Y','N');"/>
				<html:hidden property="isIgnoreError" value="<%= CommonUtil.nullToString(bbaForm.getIsIgnoreError()) %>" />
				<U>I</U>gnore Error
			</td>
		</tr>
		<tr>
			<td valign="top" NOWRAP class="none">
				<input type="checkbox" name="isShowRealNameTmp" id="idShReal_name" accessKey="r" <%= CommonUtil.nullToString(bbaForm.getIsShowRealName()).equals("Y")? "checked": "" %> onclick="javascript:doTickWithValue('isShowRealName', 0, 'Y','N');"/>
				<html:hidden property="isShowRealName" value="<%= CommonUtil.nullToString(bbaForm.getIsShowRealName()) %>" />
				Show <U>R</U>eal PK name
			</td>
		</tr>
		<tr>
			<td valign="top" NOWRAP class="none">
				<input type="checkbox" name="isSingleStmtTmp" id="idSingle_stmt" accessKey="t" <%= CommonUtil.nullToString(bbaForm.getIsSingleStmt()).equals("Y")? "checked": "" %> onclick="javascript:doTickWithValue('isSingleStmt', 0, 'Y','N');"/>
				<html:hidden property="isSingleStmt" value="<%= CommonUtil.nullToString(bbaForm.getIsSingleStmt()) %>" />
				Use Single Statemen<U>t</U>
			</td>
		</tr>
		<tr>
			<td valign="top" class="none">
			<BR></td>
		</tr>
		<tr>
			<td valign="top" class="none">
			<B>Special commands :</B></td>
		</tr>
		<tr>
			<td valign="top" class="none">
			&nbsp; &nbsp;bba.dump [table name]</td>
		</tr>
		<tr>
			<td valign="top" class="none">
			&nbsp;&nbsp; sp_helptext [table name]</td>
		</tr>
		</table></td>
	<td valign="top" WIDTH="5%" class="none"></td>
	<td valign="top">
<html:textarea property="inputQuery" accesskey="y" rows="15" cols="95" />
	</td>
</tr>
</table>


<bean:write name="bbaForm" property="outputHTML" filter="false" />

</html:form>
</BODY>
</HTML>